<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of register
 *
 * @author Johannes
 */
require_once("dbc.class.php");
class register extends dbc {
    
    private $username;
    private $password;
    private $password2;
    private $email;
    private $firstname;
    private $lastname;
    
    private $errors;

    public function __contruct() {
        parent::_contruct();
        
//        $this->username = $this->cleaner($_POST['username']);
//        $this->password = $this->cleaner($_POST['password']);
//        $this->password2 = $this->cleaner($_POST['password2']);
//        $this->email = $this->cleaner($_POST['email']);
//        $this->firstname = $this->cleaner($_POST['firstname']);
//        $this->lastname = $this->cleaner($_POST['lastname']);
        
        $this->errors = array();
    }
    
    public function registerUser() {
        $dbc = $this->dbc();
        
        $this->username = $this->cleaner(@$_POST['username']);
        $this->password = $this->cleaner(@$_POST['password']);
        $this->password2 = $this->cleaner(@$_POST['password2']);
        $this->email = $this->cleaner($_POST['email']);
        $this->firstname = $this->cleaner(@$_POST['firstname']);
        $this->lastname = $this->cleaner(@$_POST['lastname']);
        
        if($_POST['check'] == "users") {
            if(!empty($this->username) || !empty($this->password) || !empty($this->email) || !empty($this->firstname) || !empty($this->lastname) && $this->password == $this->password2) {
                $sql = "INSERT INTO users SET username='{$this->username}', password='{$this->password}', email='{$this->email}', 
                        firstname='{$this->firstname}', lastname='{$this->lastname}'";
                $data = $this->query($sql);
            }
        }
    }
    
    public function cleaner($string) {
        return $this->escape($string);
    }
    
 
    
}

?>
